package com.kaiyiweitong.tongxing.activity.my;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;

import com.kaiyiweitong.tongxing.R;
import com.kaiyiweitong.tongxing.activity.my.setting.AccountSafeActivity;
import com.kaiyiweitong.tongxing.activity.my.setting.ChangePswActivity;
import com.kaiyiweitong.tongxing.activity.my.setting.ServiceAddressActivity;
import com.kaiyiweitong.tongxing.base.BaseActivity;
import com.kaiyiweitong.tongxing.widget.ExitLoginDialog;

import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Administrator on 2017/12/17 0017.
 */

public class SettingActivity extends BaseActivity {

    private ExitLoginDialog mDialog;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting);
        ButterKnife.bind(this);
        mDialog = new ExitLoginDialog(this);
    }

    @OnClick({R.id.exit_login, R.id.account_safe, R.id.service_address, R.id.change_psw})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.account_safe:
                go2Page(AccountSafeActivity.class);
                break;
            case R.id.service_address:
                go2Page(ServiceAddressActivity.class);
                break;
            case R.id.change_psw:
                go2Page(ChangePswActivity.class);
                break;
            case R.id.exit_login:
                exitLogin();
                break;
        }
    }

    private void exitLogin() {
        mDialog.show();
        mDialog.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mDialog.dismiss();
            }
        });

        mDialog.findViewById(R.id.confirm).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mDialog.dismiss();
                System.exit(0);
            }
        });
    }

    private void go2Page(Class clazz) {
        Intent intent = new Intent(this, clazz);

        startActivity(intent);
    }
}
